<?php
   header("Content-Type: application/xml; charset=utf-8");
   echo "<?xml version=\"1.0\"?>\n";
   echo "<rss version=\"2.0\">";

   /********************************************************************************
    * File: rss.php
    * Desc: Returns RSS v0.92 feed for last 20 flickr photos.
    ********************************************************************************/
   require_once("inc/config.php");

   //
   // Generate items for the last 20 photos
   //
   $photoSearchParams = array(
   "user_id"=>$config_flickrUserId, 
   "tags"=>$config_flickrTags, 
   "extras"=>"original_format,date_taken,date_uploaded", 
   "per_page"=>"20", 
   "page"=>"1");

   $photos = $f->photos_search($photoSearchParams);
   $userInfo = $f->people_getInfo($config_flickrUserId);
   $items = "";
   foreach ($photos['photo'] as $photo) {
      $photoInfo = $f->photos_getInfo($photo['id']);
      $date = getdate(strtotime($photoInfo['dates']['taken']));
      $items .=   
      "     <item>" . "\n" .
      "        <title>" . htmlentities($photo['title'], ENT_QUOTES) . "</title>" . "\n" .
      "        <link>" . $config_siteUrl . "/index.php?id=" . $photo['id'] . "</link>" . "\n" .
      "        <guid>" . $config_siteUrl . "/index.php?id=" . $photo['id'] . "</guid>" . "\n" .
      "        <description>" . "\n" . 
      "           &lt;a href=&quot;" . $config_siteUrl . "/index.php?id=" . $photo['id'] . "&quot;&gt;" . "\n" .
      "              &lt;img style=&quot;border:0;&quot; src=&quot;" . $f->buildPhotoURL($photo) . "&quot;/&gt;" . "\n" .
      "           &lt;/a&gt;" . "\n" .
      "           &lt;p&gt;" . htmlentities($photoInfo['description'], ENT_QUOTES) . "&lt;/p&gt;" . "\n" .
      "           &lt;p&gt;" . $date[month] . " " . $date[mday] . ", " . $date[year] . "&lt;/p&gt;" . "\n" .
      "        </description>" . "\n" .
      "     </item>\n";
   }
?>
<channel>
      <title><?php echo $config_siteTitle; ?></title>
      <link><?php echo $config_siteUrl; ?></link>
      <description><?php echo $config_siteDescription; ?></description>   
      <language>en-us</language>
      <image>
         <url>http://farm<?php echo $userInfo['iconfarm']; ?>.static.flickr.com/<?php echo $userInfo['iconserver']; ?>/buddyicons/<?php echo $userInfo['nsid'];?>.jpg</url>
         <title><?php echo $config_siteTitle; ?></title>
         <link><?php echo $config_siteUrl;?></link>
      </image>
      <?php echo $items; ?>
   </channel>
</rss>